package com.cardone.common.security;

import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.jasypt.util.text.TextEncryptor;

/**
 * Created by c100000002 on 15-1-28.
 */
@Slf4j
public class DesTextEncryptor implements TextEncryptor {
    @Setter
    private String password;


    @Override
    public String encrypt(String message) {
        try {
            return DESCipher.newDESCipher(password).encrypt(message);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }

        return null;
    }

    @Override
    public String decrypt(String encryptedMessage) {
        try {
            return DESCipher.newDESCipher(password).decrypt(encryptedMessage);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }

        return null;
    }
}
